package cn.t17.appsys.controller;

import cn.t17.appsys.dto.CommonResponse;
import cn.t17.appsys.entity.DevUser;
import cn.t17.appsys.service.DevUserService;
import cn.t17.appsys.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * DevUserLoginController class
 *
 * @author Administrator
 * @date 2021/9/16
 */
@CrossOrigin(allowCredentials = "true")
@RestController
@RequestMapping("dev")
public class DevUserLoginController extends BaseController {

    @Autowired
    private DevUserService devUserService;
    @RequestMapping(value = "dologin", method = RequestMethod.POST)
    public CommonResponse<?> doLogin(@RequestParam String devCode,
                                     @RequestParam String devPassword,
                                     HttpSession session) {
        // ...
        DevUser devUser = devUserService.login(devCode, devPassword);
        session.setAttribute(Constants.SESSION_USER,devUser);
        return success("登录成功");
    }

}
